//
//  PlayerManager.h
//  DiceWar
//
//  Created by xiaofeng on 29/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#ifndef CLASS_GAME_PLAYER_PLAYERSMANAGER_H_
#define CLASS_GAME_PLAYER_PLAYERSMANAGER_H_

#include "GameMaster.h"
#include "SharedPointer.h"
#include <vector>

class PlayersManager
{
public:
    PlayersManager();
    ~PlayersManager();
    
    bool start();
    void gotoNextPlayer();

    int getNumAlivePlayers() const;
    bool isHumanPlayerAlive() const;

    PlayerType getCurrentPlayer() const;
    
private:
    bool createPlayersForPlayerVsPlayer(int numPlayers);
    bool createPlayersForPlayerVsAI(int numPlayers, PlayerType type);
    
    Player* createHumanPlayer(PlayerType type); 
    Player* createRobotPlayer(PlayerType type);
    
    void releaseAllPlayers();
    void startRound();
    int getNumPlayers();
    
private:
    typedef std::vector<Player*> PlayersVec;
    PlayersVec m_players;
    int m_currentPlayerIndex;
};

#endif //CLASS_GAME_PLAYER_PLAYERSMANAGER_H_
